

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Model XSD [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Code Engineering,Code Engineering XML Schema, Model XSD,XSD,XSD Model,Model,Model XSD">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Model XSD</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="xml_schema_xsd.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="uml_profile_for_xsd.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText">XML schemas are modeled using UML <a href="classdiagram.htm">Class</a> diagrams. The </span><span class="f_UIControl"><a href="xmlschemagroup.htm">XML Schema</a></span><span class="f_BodyText"> pages of the Enterprise Architect UML </span><span class="f_UIControl">Toolbox</span><span class="f_BodyText"> provide in-built support for the <a href="http://www.sparxsystems.com/xml_schema_generation.htm" target="_blank" class="weblink">UML profile for XSD</a>. This enables an abstract UML Class model to be automatically generated as a <a href="http://www.w3.org/XML/Schema" target="_blank" class="weblink">W3C XML Schema</a> (XSD) file.</span></p>
<p class="p_BodyText"><span class="f_BodyText">The following Class diagram models simple schema for an example </span><span class="f_BodyText" style="font-style: italic;">Employee Details</span><span class="f_BodyText"> system, intended to store a company's employee contact information. The Classes shown form the </span><span class="f_BodyText" style="font-style: italic;">EmployeeDetails</span><span class="f_BodyText"> package. The UML attributes of the Classes map directly to XML elements or attributes. Note that the Classes have no methods, since there is no meaningful correspondence between Class methods and XSD constructs.</span></p>
<p class="p_TextIndentedL2"><img src="genxsdstereotypeexample.png" width="582" height="531" border="0" alt="GenXSDStereotypeExample"></p>
<p class="p_BodyText"><span class="f_BodyText">The following code shows the schema generated for the </span><span class="f_BodyText" style="font-style: italic;">Employee Details</span><span class="f_BodyText"> package by default. Notice how each UML Class corresponds to a </span><span class="f_BodyText" style="font-style: italic;">complexType</span><span class="f_BodyText"> definition in the schema. The Class attributes are generated as schema elements contained in a Sequence model group within the definition. The </span><span class="f_BodyText" style="font-style: italic;">Enumeration</span><span class="f_BodyText"> Class is the exception here - it maps directly to an XSD enumeration, contained within a </span><span class="f_BodyText" style="font-style: italic;">simpleType</span><span class="f_BodyText"> definition.</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_Code"><span class="f_Code">&lt;?xml version=&quot;1.0&quot;?&gt;</span></p>
<p class="p_Code"><span class="f_Code">&lt;xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;ContactInfo&quot; type=&quot;ContactInfo&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:complexType name=&quot;ContactInfo&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:sequence&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;ContactInfo.homePhone&quot; type=&quot;xs:string&quot; maxOccurs=&quot;1&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;ContactInfo.email&quot; type=&quot;xs:string&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;ContactInfo.streetAddress&quot; type=&quot;xs:string&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:choice&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;ContactInfo.mobilePhone&quot; type=&quot;xs:string&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;ContactInfo.officePhone&quot; type=&quot;xs:string&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:choice&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:sequence&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:complexType&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:simpleType name=&quot;Gender&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:restriction base=&quot;xs:string&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:pattern value=&quot;male|female&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:restriction&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:simpleType&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;Employee&quot; type=&quot;Employee&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:complexType name=&quot;Employee&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:complexContent&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:extension base=&quot;Person&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:sequence&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;status&quot; type=&quot;Status&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;jobTitle&quot; type=&quot;xs:string&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;startDate&quot; type=&quot;xs:date&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;department&quot; type=&quot;xs:string&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:sequence&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:extension&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:complexContent&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:complexType&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;Person&quot; type=&quot;Person&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:complexType name=&quot;Person&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:sequence&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;surName&quot; type=&quot;xs:string&quot; maxOccurs=&quot;1&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;firstName&quot; type=&quot;xs:string&quot; maxOccurs=&quot;1&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;birthDate&quot; type=&quot;xs:string&quot; maxOccurs=&quot;1&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;contactDetails&quot; type=&quot;ContactInfo&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:sequence&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:attribute name=&quot;gender&quot; use=&quot;optional&quot; type=&quot;Gender&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:complexType&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;EmployeeRecords&quot; type=&quot;EmployeeRecords&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:complexType name=&quot;EmployeeRecords&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:all&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:element name=&quot;Employee&quot; type=&quot;Employee&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:all&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:complexType&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:simpleType name=&quot;Status&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:restriction base=&quot;xs:string&quot;&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:enumeration value=&quot;Full-Time&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:enumeration value=&quot;Part-Time&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;xs:enumeration value=&quot;Casual&quot;/&gt;</span></p>
<p class="p_Code"><span class="f_Code">` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;xs:enumeration value=&quot;Contract&quot;/&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:restriction&gt;</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">&lt;/xs:simpleType&gt;</span></p>
<p class="p_Code"><span class="f_Code">&lt;/xs:schema&gt;</span></p>
<p class="p_Code"><span class="f_Code">&nbsp;</span></p>
<p class="p_BodyText"><span class="f_BodyText">The following topics provide further explanation:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1" style="font-style: italic;"><a href="uml_profile_for_xsd.htm">UML Profile for XSD</a></span></li>
<li><span class="f_Bulletlist1" style="font-style: italic;"><a href="xsd_datatype_package.htm">XSD Datatypes Package</a></span></li>
<li><span class="f_Bulletlist1" style="font-style: italic;"><a href="abstract_xsd_models.htm">Abstract XSD Models</a></span></li>
</ul>




            </div>
          </div>
        </div>



</div>


</body>
</html>
